package com.cci.kangdao.utilTool;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

//import com.cci.kangdao.common.push.GeTuiConfig;
//import com.cci.kangdao.common.push.PushService;
//import com.cci.kangdao.common.push.UmengConfig;
import com.cci.kangdao.common.push.GeTuiConfig;
import com.cci.kangdao.common.push.PushService;
import com.cci.kangdao.common.push.UmengConfig;
import com.gexin.rp.sdk.base.IPushResult;

/**
 * 消息推送
 * @author Eric
 *
 */
public class NotifyUtil {


	private static GeTuiConfig geTuiConfig = new GeTuiConfig();
	private static UmengConfig umengConfig = new UmengConfig();
	private static PushService pushService;
	private static NotifyUtil pushServiceStaic = new NotifyUtil();


	static{
		init();
	}

	/**
	 * 数据初始化
	 */
	private static void init() {
		Properties properties = new Properties();
		String type = "";
		try {
			InputStream inputStream = MailUtil.class.getClassLoader().getResourceAsStream("projectconfig.properties");
			properties.load(inputStream);
			inputStream.close();
			type = properties.getProperty("type");

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if ("getui".equals(type)) {
			pushService = geTuiConfig;
		} else if ("umeng".equals(type)) {
			pushService = umengConfig;
		}
	}

	public static boolean push2Single(String cId, String title, String content, int transmissionType, String transmissionContent) {
		return pushServiceStaic.pushService.push2Single(cId, title, content, transmissionType, transmissionContent);
	}
	/**
	 *
	 * @param cId
	 * @param content 通知消息体
	 * @param transmissionContent 透传内容
	 */
	public static boolean push2Single(String cId, String content, String transmissionContent) {
		return push2Single(cId, null, content, 2, transmissionContent);
	}
	public static IPushResult pushMessageToApp(String content, int transmissionType, String transmissionContent){
		return pushServiceStaic.pushService.pushMessageToApp(content, transmissionType, transmissionContent);
	}
}
